home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 December / Australian PC User - December 2003 (CD2).iso / software / apps / files / dwmx2k4.exe / Disk1 / data1.cab / Configuration_En / Components / Common / ComponentCommon.js next >
Encoding:
JavaScript  |  2003-09-05  |  7.1 KB  |  273 lines

  1. // Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. //--------------------------------------------------------------------
  4. // CLASS:
  5. //   ComponentRec
  6. //
  7. // DESCRIPTION:
  8. //  This class encapsulates a component record in Server Components 
  9. //  Panel
  10. //
  11. // PUBLIC FUNCTIONS:
  12. //  getName        -   returns the name of the component object using the this object.
  13. //
  14. //  getImageFile   -   returns the image file name to display for 
  15. //
  16. //  hasChildren    -   returns whether it has children or not.
  17. //
  18. //  getToolTipText -   get the tool tip text for this node.
  19. //
  20. //  IsDraggable    -   determines whether the object can be dragged or dropped.
  21. //
  22. //--------------------------------------------------------------------
  23.  
  24.  
  25. var PROPERTIES_FILENAME     = "Shared/MM/Images/DSL_D.gif";
  26. var METHODS_FILENAME        = "Shared/MM/Images/DSL_D.gif";
  27. var PLUSBUTTONUP            = "Shared/MM/Images/btnAdd.gif";
  28. var PLUSBUTTONDOWN            = "Shared/MM/Images/btnAdd_sel.gif";
  29. var MINUSBUTTONUP            = "Shared/MM/Images/btnDel.gif";
  30. var MINUSBUTTONDOWN            = "Shared/MM/Images/btnDel_sel.gif";
  31. var MINUSBUTTONDISABLED        = "Shared/MM/Images/btnDel_dis.gif";
  32. var PLUSDROPBUTTONUP        = "Shared/MM/Images/btnAddDrop.gif";
  33. var PLUSDROPBUTTONDOWN        = "Shared/MM/Images/btnAddDrop_sel.gif";
  34.  
  35.  
  36. //-------------------------------------------------------------------
  37. // FUNCTION:
  38. //   ComponentRec
  39. //
  40. // DESCRIPTION:
  41. //     constructs component rec objects
  42. //
  43. // ARGUMENTS:
  44. //     name            : of the node to appear in the component tree.
  45. //     imageFile        : the image for the node.
  46. //     allowDelete    : allowDeleting the node.
  47. //     hasChildren    : the node has further children
  48. //     tooliptext        : the tooltip text for this node.
  49. //     contextmenu    : the context menu for this node.
  50. //
  51. // RETURNS:
  52. //   componentRec
  53. //--------------------------------------------------------------------
  54. function ComponentRec(name,imageFile,bHasChildren,bIsDraggable,toolTipText,bAllowDelete,bIsDesignViewDraggable)
  55. {
  56.     this.name = name;
  57.     this.image = imageFile;
  58.     this.hasChildren = bHasChildren;
  59.     this.toolTipText = toolTipText;
  60.     this.isCodeViewDraggable = bIsDraggable;
  61.     if (arguments.length > 5)
  62.     {
  63.         this.allowDelete = bAllowDelete;
  64.     }
  65.     if (arguments.length > 6)
  66.     {
  67.         this.isDesignViewDraggable = bIsDesignViewDraggable;
  68.     }
  69. }
  70.  
  71. // public methods
  72. ComponentRec.prototype.getName            = componentRec_getName;
  73. ComponentRec.prototype.getImageFile        = componentRec_getImageFile;
  74. ComponentRec.prototype.hasChildren        = componentRec_hasChildren;
  75. ComponentRec.prototype.getToolTipText    = componentRec_getToolTipText;
  76. ComponentRec.prototype.IsDraggable        = componentRec_IsDraggable;
  77.  
  78. //-------------------------------------------------------------------
  79. // FUNCTION:
  80. //   componentRec_getName
  81. //
  82. // DESCRIPTION:
  83. //     returns the name of the component object using the this object.
  84. //
  85. // ARGUMENTS:none
  86. //
  87. // RETURNS:
  88. //   a string.
  89. //--------------------------------------------------------------------
  90. function componentRec_getName()
  91. {
  92.     return this.name;
  93. }
  94.  
  95. //-------------------------------------------------------------------
  96. // FUNCTION:
  97. //   componentRec_getImageFile
  98. //
  99. // DESCRIPTION:
  100. //     returns the image file name to display for 
  101. //
  102. // ARGUMENTS:none
  103. //
  104. // RETURNS:
  105. //   a string.
  106. //--------------------------------------------------------------------
  107. function componentRec_getImageFile()
  108. {
  109.     return this.imageFile;
  110. }
  111.  
  112.  
  113. //-------------------------------------------------------------------
  114. // FUNCTION:
  115. //   componentRec_hasChildren
  116. //
  117. // DESCRIPTION:
  118. //     returns whether it has children or not.
  119. //
  120. // ARGUMENTS:none
  121. //
  122. // RETURNS:
  123. //   a string.
  124. //--------------------------------------------------------------------
  125. function componentRec_hasChildren()
  126. {
  127.     return this.hasChildren;
  128. }
  129.  
  130. //-------------------------------------------------------------------
  131. // FUNCTION:
  132. //   componentRec_getToolTipText
  133. //
  134. // DESCRIPTION:
  135. //     get the tool tip text for this node.
  136. //
  137. // ARGUMENTS:none
  138. //
  139. // RETURNS:
  140. //   a string.
  141. //--------------------------------------------------------------------
  142. function componentRec_getToolTipText()
  143. {
  144.     return this.toolTipText;
  145. }
  146.  
  147.  
  148. //-------------------------------------------------------------------
  149. // FUNCTION:
  150. //   componentRec_IsDraggable
  151. //
  152. // DESCRIPTION:
  153. //     determines whether the object can be dragged or dropped.
  154. //
  155. // ARGUMENTS:none
  156. //
  157. // RETURNS:
  158. //   a string.
  159. //--------------------------------------------------------------------
  160. function componentRec_IsDraggable()
  161. {
  162.     return this.isCodeViewDraggable;
  163. }
  164.  
  165. //-------------------------------------------------------------------
  166. // FUNCTION:
  167. //   ToolbarRec
  168. //
  169. // DESCRIPTION:
  170. //     constructs toolbar rec objects
  171. //
  172. // ARGUMENTS:
  173. //     image            : the image for the node.
  174. //     pressedImage    : the pressed image for the node.
  175. //     disabledImage    : the node has further children
  176. //     tooliptext        : the tooltip text for this node.
  177. //     toolStyle        : the stlye of the toolbar(left/right).
  178. //     onClick        : the onClick event hanlder.
  179. //
  180. // RETURNS:
  181. //   ToolBarRec
  182. //--------------------------------------------------------------------
  183. function ToolbarControlRec(image,pressedImage,disabledImage,tooltiptext,toolStyle,onClick)
  184. {
  185.     this.image= image;
  186.     this.pressedImage = pressedImage;
  187.     this.disabledImage = disabledImage;
  188.     this.toolTipText = tooltiptext;
  189.     this.toolstyle =toolStyle;
  190.     this.command = onClick;
  191. }
  192.  
  193.  
  194. //*-------------------------------------------------------------------
  195. // FUNCTION:
  196. //   clickedDatabaseInsert()
  197. //
  198. // DESCRIPTION:
  199. //        drops code into code view.
  200. //
  201. // ARGUMENTS:
  202. //    
  203. // RETURNS:
  204. //--------------------------------------------------------------------
  205. function clickedInsert()
  206. {
  207.   var insertText="";
  208.     var dom = dw.getDocumentDOM();
  209.     if (dom)
  210.     {
  211.         var aNode = dw.serverComponentsPalette.getSelectedNode();
  212.         if (aNode && aNode.isCodeViewDraggable)
  213.         {
  214.             insertText = getCodeViewDropCode(aNode);
  215.             var selection = dom.source.getSelection();
  216.             dom.source.replaceRange(selection[0],selection[1],insertText);
  217.         }
  218.     }
  219. }
  220.  
  221.  
  222. //*-------------------------------------------------------------------
  223. // FUNCTION:
  224. //   clickedInsert()
  225. //
  226. // DESCRIPTION:
  227. //        drops code into code view.
  228. //
  229. // ARGUMENTS:
  230. //    
  231. // RETURNS:
  232. //--------------------------------------------------------------------
  233. function clickedInsert(aNode)
  234. {
  235.   var insertText="";
  236.     var dom = dw.getDocumentDOM();
  237.     if (dom)
  238.     {
  239.         if (aNode && aNode.isCodeViewDraggable && (dw.getFocus() == 'textView'))
  240.         {
  241.             insertText = getCodeViewDropCode(aNode);
  242.             var selection = dom.source.getSelection();
  243.             dom.source.replaceRange(selection[0],selection[1],insertText);
  244.         }
  245.     }
  246. }
  247.  
  248.  
  249. //*-------------------------------------------------------------------
  250. // FUNCTION:
  251. //   enabledInsert()
  252. //
  253. // DESCRIPTION:
  254. //        checks to see to enable the insert menu option.
  255. //
  256. // ARGUMENTS:
  257. //    
  258. // RETURNS:
  259. //--------------------------------------------------------------------
  260. function insertEnabled(aNode)
  261. {
  262.   var enable=false;
  263.     var dom = dw.getDocumentDOM();
  264.     if (dom)
  265.     {
  266.         if (aNode && aNode.isCodeViewDraggable && (dw.getFocus() == 'textView'))
  267.         {
  268.                 enable = true;
  269.         }
  270.     }
  271.     return enable;
  272. }
  273.